<%@include file="connection.jsp" %>

<%
int rec=Integer.parseInt(request.getParameter("rec").toString());
//int rec=4;
int pg=Integer.parseInt(request.getParameter("page").toString());
int n=0;
int off=rec*pg;
st=con.createStatement();
rs=st.executeQuery("select COUNT(sr_no) from user");

while(rs.next()){
    n=rs.getInt(1);
    
}
//if(n%rec==0){
    
//}
String sql="select * from user limit "+off+","+rec;
rs=st.executeQuery(sql);

%>  
        <div id="box">
            <h3>Users</h3>
            <table border='1'>
                         <thead>
                             <tr>
                            <th><center><b>Sr No</b></center></th>
                            <th><center><b>Name</b></center></th>
                            <th><center><b>ID</b></center></th>
                            <th><center><b>Mobile NO</b></center></th>
                            <th><center><b>Package</b></center></th>
                            <th><center><b>Sub_St_Date</b></center></th>
                            <th><center><b>Operations</b></center></th>
                            </tr>
                    </thead>
                        <%   
                        
                        while(rs.next())
                        {
                            out.print("<tr>");
                                                                           
                            out.print("<td>");
                            out.print(rs.getString(1));
                            out.print("</td>");
                            
                            out.print("<td>");
                            out.print(rs.getString(3)+" "+rs.getString(4));
                            out.print("</td>");

                            out.print("<td>");
                            out.print(rs.getString(2));
                            out.print("</td>");
    
                            out.print("<td>");
                            out.print(rs.getString(6));
                            out.print("</td>");

                            out.print("<td>");
                            out.print(rs.getString(7));
                            out.print("</td>");

                            out.print("<td>");
                            out.print(rs.getString(8));
                            out.print("</td>");
                            
                            out.print("<td>");
                            out.print("<a href='user_update.jsp?id="+rs.getString(1)+"'><img src='img/icons/user_edit.png'></a>");
                            out.print("<a href='user_delete.jsp?id="+rs.getString(1)+"'><img src='img/icons/user_delete.png'></a>");
                            out.print("</td>");
                            

                        }
                        rs.close();
                        %>
                        
                     </table>
        </div>
                        <div id="pagena">
                            <select id="sel" onchange="abc()">
       <%
       //int rec=Integer.parseInt(request.getParameter("rec").toString());
            
            if(n%rec==0){
                for(int i=0;i<n/rec;i++)
                out.print("<option value='"+i+"'>"+(i+1)+"</option>");
            }
            
                                   else{
                                        for(int i=0;i<n/rec+1;i++)
                                        out.print("<option value='"+i+"'>"+(i+1)+"</option>");
                            
                                   }
                
                    
       


       %>                 </select>
                        </div>            
